package cn.itcast.user.service;

import cn.itcast.user.mapper.UserMapper;
import cn.itcast.user.pojo.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService{

    private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);

    @Autowired
    private UserMapper userMapper;

    @Override
//    @Async("taskExecutor")
    public User queryById(Long id) {
        logger.info("开始");
        User user = userMapper.findById(id);
//        try {
//            TimeUnit.SECONDS.sleep(3);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        logger.info("结束");
        return user;
    }


//    @Override
//    @Async("taskExecutor")
//    public Future<User> queryById(Long id) {
//        logger.info("开始");
//        User user = userMapper.findById(id);
////        try {
////            TimeUnit.SECONDS.sleep(3);
////        } catch (InterruptedException e) {
////            e.printStackTrace();
////        }
//        logger.info("结束");
////        return user;
//        System.out.println(Thread.currentThread().getId());
//        return new AsyncResult(user);
//    }


}
